package com.greenx.hello.collections;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

/**
 * 
 * @author StephenXianweiZhang
 * 
 */
public class HelloCollections {

	private static List<String> listA = new ArrayList<String>();
	private static List<String> listB = new ArrayList<String>();

	private static Map<Long, List<String>> orgAndUserSSOIDMap = new HashMap<Long, List<String>>();

	/**
	 * @param args
	 */
	@SuppressWarnings({ "unchecked" })
	public static void main(String[] args) {

		testClone();
		// Map<String, String> userObject = new HashMap<String, String>();
		// System.out.println(userObject.get("IDP_USER_ID"));
		// t2(userObject);
		// System.out.println(userObject.get("IDP_USER_ID"));

	}

	private static void testClone() {
		ArrayList<String> l = new ArrayList<String>();
		l.add("Hello");
		l.add("World");

		List<String> lc = (List<String>) l.clone();
		List<String> lcTMP = l;
		l.add("!");

		for (String str : l) {
			System.out.print(str);

		}
		System.out.println("\n");
		for (String str : lc) {
			System.out.print(str);
		}
		System.out.println("\n");
		for (String str : lcTMP) {
			System.out.print(str);
		}
		System.out.println("\n");

	}

	private static void testOrder() {
		Map m1 = new HashMap();
		m1.put("map", "HashMap");
		m1.put("schildt", "java2");
		m1.put("mathew", "Hyden");
		m1.put("schildt", "java2s");
		System.out.println(m1.keySet());
		System.out.println(m1.values());

		SortedMap sm = new TreeMap();
		sm.put("map", "TreeMap");
		sm.put("schildt", "java2");
		sm.put("mathew", "Hyden");
		sm.put("schildt", "java2s");
		System.out.println(sm.keySet());
		System.out.println(sm.values());

		LinkedHashMap lm = new LinkedHashMap();
		lm.put("map", "LinkedHashMap");
		lm.put("schildt", "java2");
		lm.put("mathew", "Hyden");
		lm.put("schildt", "java2s");
		System.out.println(lm.keySet());
		System.out.println(lm.values());
	}

	private static void t2(Map<String, String> userObject) {
		if (userObject != null) {
			userObject.put("IDP_USER_ID", "ravi.sambhara@compuware1.com");
		}

	}

	private static void t1() {
		orgAndUserSSOIDMap.put(new Long(1), new ArrayList<String>());

		System.out.println("|" + orgAndUserSSOIDMap.get(new Long(1)) + "|");
		System.out.println("|");
		System.out.println("|");
		System.out.println("|");
		System.out.println("|");
		for (int i = 0; i < 2000; i++) {
			if (orgAndUserSSOIDMap.get(new Long(1)) == null) {
				listA.add("helloA");
				orgAndUserSSOIDMap.put(new Long(1), listA);
			} else {
				orgAndUserSSOIDMap.get(new Long(1)).add("test" + i);
			}

		}
		System.out.println("|" + orgAndUserSSOIDMap.get(new Long(1)) + "|");

		// System.out.println("str:  " + listA.size());
		// listA.add("helloA");
		// listA.add("helloB");
		// listA.add("helloC");
		//
		// listB.add("helloB");
		// listB.add("helloC");
		// listB.add("helloD");
		//
		// Collection<String> removeList = CollectionUtils.subtract(listA,
		// listB);
		// for (String str : removeList) {
		// System.out.println("str:  " + str);
		// }
		//
		// Collection<String> addList = CollectionUtils.subtract(listB, listA);
		// for (String str : addList) {
		// System.out.println("str:  " + str);
		// }
	}
}
